<?php


/**
 * Description of Category
 *
 * @author Admin
 */
class Asset_Model_Category extends WOW_Model_Acl_Abstract
{
    
    public function getResourceId()
    {
        return 'Category';
    }

    public function getCategoryById($id)
    {
        $id = (int) $id;
        return $this->getResource('Category')->getCategoryById($id);
    }

    public function getCategoryByIdent($ident)
    {
        return $this->getResource('Category')->getCategoryByIdent($ident);
    }

    public function getAllCategories()
    {
         return $this->getResource('Category')->getAllCategories();
    }


    public function getAllCategoryArray()
    {
        $allcat  = $this->getResource('Category')->getAllCategories();        
        $ret_ar = array(' ' => 'Select Category');
        foreach($allcat as $cat)
        {
            $ret_ar[$cat->catid] = $cat->CategoryName;
        }
        
        return $ret_ar;
    }

    #@ TODO:: needs to be worked on ACL later
    public function setAcl(WOW_Acl_Interface $acl)
    {
        if (!$acl->has($this->getResourceId()))
        {
            $acl->add($this)->allow('Normal', $this, array('register'))
            ->allow('Moderator', $this, array('saveCategory'))
                    ->allow('Admin', $this);
        }
        $this->_acl = $acl;
        return $this;
    }

    public function getAcl()
    {
        if (null === $this->_acl) {
            $this->setAcl(new Main_Model_Acl_Main());
        }
        return $this->_acl;
    }

}
?>
